home *** CD-ROM | disk | FTP | other *** search
- Path: hermes.louisville.edu!starbase!gclind01
- From: gclind01@starbase.spd.louisville.edu (George C. Lindauer)
- Newsgroups: comp.os.msdos.programmer,comp.lang.c
- Subject: Re: Pointer Stew...
- Date: 6 Feb 1996 20:00:05 GMT
- Organization: University of Louisville, Louisville KY USA
- Message-ID: <4f8c05$79m@hermes.louisville.edu>
- References: <svsFxc9nXUNB083yn@mbnet.mb.ca>
- NNTP-Posting-Host: starbase.spd.louisville.edu
- X-Newsreader: NN version 6.5.0 CURRENT #16
-
- natewild@mbnet.mb.ca (Nathan T. Wild) writes:
-
- >I am implimenting a system, but which executable code modules are loaded
- >from disk files into allocated blocks.
-
- >This is working very well. I allocated a big enough block, load the
- >"driver" in and aim a function pointer ar it.
-
- >What I would like to do is have the code that I load in contain near
- >pointers to it's own groups of functions. I have placed a header on the
- >driver module I wish to load that contains the offset from the current
- >segment for two functions contained within the driver block.
-
- >This time I want to calculate the segment and read in the offset and set
- >both function pointers accordingly.
-
- >I am having difficulty dereferencing things???
-
-
-
- >Say, for example that my code block is allocated at XXXX:0004. The first 2
- >bytes are the pointer (within the block) to the first function and the next
- >2 bytes are the pointer to the second function.
-
- >I want to set my function pointer to the segment XXXX and the offset stored
- >at XXXX:0004 & 0005. No matter how I reference this, I get my function
- >pointing to XXXX:0004!
-
-
- >I have tried (where driverPtr == XXXX:0004 and is a void far *):
- > func1ptr = (void far **)driverPtr
- > func2ptr = (void far **)(driverPtr+2)
- >
- >But I get XXXX:0004 every time? I can set the function pointers to what I
- >want if I use MK_FP(), FP_SEG() and peek(), but there has got to be a
- >better way than this?
-
- I would use MK_FP (it uses compiler primitives that manage segments and offsets)
- , but you might get away with:
-
- func1ptr = (void far *)(*(short *)driverPtr);
- func2ptr = (void far *)(*(short *)(driverPtr+2));
-
- Of course that last +2 may not work because driverPtr is void far *,
- so you may have to do something like:
-
- func2ptr = (void far *)(*(((short *)driverPtr)+1));
-
- And maybe unsigned shorts would be smarter, I don't know.
- And this still doesn't handle segments appropriately. Oh well...
-
-
-
- >In short, how, given the address of a stored pointer, set a function to
- >point to the address stored, no to the location it is stored in???
-
- >This is driving me nuts as I am sure it is fairly simple...
-
- >Please respond via Email, I cannot access this group "live"...
-
- >Thanks in advance...
-
- >|--------------------------------------------------------------------|
- >| ooooO (``) (``) Ooooo | Nathan T. Wild |
- >| ( ) ) ( ) ( ( ) | natewild@mbnet.mb.ca |
- >| ) ( ( ) ( ) ) ( | ftp://ftp.mbnet.mb.ca/pub/natewild |
- >| (__) ooooO Ooooo (__) | http://www.mbnet.mb.ca/~natewild |
- >|--------------------------------------------------------------------|
-